import instance from "./utils/http";

export function getLoop(number) {
    return instance.get(`/api/weChat/applet/course/banner/list?number=${number}`)
}

export function getList(type, keyword = '') {
    let params = new URLSearchParams();
    params.append("type", type)
    params.append("pageNum", 1)
    params.append("pageSize", 5)
    if (keyword) {
        params.append("keyword", keyword)
    }
    return instance.post(`/api/weChat/applet/course/list/type`, params)
}

export function getCourseDetail(courseId) {
    return instance.get(`api/pc/course/detail/${courseId}`)
}

export function searchCourses(params) {
    return instance.get('api/pc/course/search/keyword', {
        params: {
            pageNum: params.pageNum || 1,
            pageSize: params.pageSize || 15,
            type: params.type,               
            subjectId: params.subjectId,     
            courseType: params.courseType,   
            keyword: params.keyword          
        }
    });
}

export function getLogin(username, password) {
    let params = new URLSearchParams
    params.append("username", username)
    params.append("password", password)
    params.append("rememberMe", false)
    return instance.post(`/api/pcUser/login`, params)
}
